<?php
?>
<div class="modal-body" id="auth_content">
    <div class="form-horizontal">
        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">名称：</label>
            <div class="col-lg-9">
                <label class="form-control"><?= $item['name'] ?></label>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">手机号：</label>
            <div class="col-lg-9">
                <label class="form-control"><?= $item['phone'] ?></label>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">电话：</label>
            <div class="col-lg-9">
                <label class="form-control"><?= $item['tel'] ?></label>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">地址：</label>
            <div class="col-lg-9">
                <label class="form-control"><?= $item['province'] . $item['city'] . $item['county'] . $item['address'] ?></label>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">启用状态：</label>
            <div class="col-lg-3">
                <label class="form-control"> <?php
                    if ($item['is_enabled'] == 1) {
                        ?>
                        <span class="label label-success">启用</span>
                        <?php
                    } else {
                        ?>
                        <span class="label label-danger">禁用</span>
                        <?php
                    }
                    ?></label>
            </div>
            <label class="col-lg-3 col-sm-3 control-label">认证状态：</label>
            <div class="col-lg-3">
                <label class="form-control"><?php
                    if ($item['is_auth'] == 1) {
                        ?>
                        <span class="label label-success">认证</span>
                        <?php
                    } else {
                        ?>
                        <span class="label label-danger">未认证</span>
                        <?php
                    }
                    ?></label>
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">营业执照注册号：</label>
            <div class="col-lg-3">
                <label class="form-control"><?= $item['registration_no'] ?></label>
            </div>
            <label class="col-lg-3 col-sm-3 control-label">营业执照扫描件：</label>
            <div class="col-lg-3">
                <img style="width: 200px" src="<?= $item['business_license_scanning_copy'] ?>">
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">法人身份证照（正面）：</label>
            <div class="col-lg-3">
                <img style="width: 200px" src="<?= $item['legal_representative_id_front_photo'] ?>">
            </div>
            <label class="col-lg-3 col-sm-3 control-label">法人身份证照（反面）：</label>
            <div class="col-lg-3">
                <img style="width: 200px" src="<?= $item['legal_representative_id_back_photo'] ?>">
            </div>
        </div>

        <div class="form-group">
            <label class="col-lg-3 col-sm-3 control-label">法人身份号：</label>
            <div class="col-lg-3">
                <label class="form-control"><?= $item['legal_representative_id_number'] ?></label>
            </div>
            <label class="col-lg-3 col-sm-3 control-label">法人手持身份证照：</label>
            <div class="col-lg-3">
                <img style="width: 200px" src="<?= $item['legal_representative_id_photo'] ?>">
            </div>
        </div>
        <?php
        if ($currentAuthRecord != null) {
            ?>
            <div class="form-group">
                <label class="col-lg-3 col-sm-3 control-label">审核意见：</label>
                <div class="col-lg-9">
                    <textarea class="form-control" id="authRemark" autofocus></textarea>
                </div>
            </div>
            <?php
        }
        ?>

    </div>

    <div class="panel">
        <div class="panel-heading">审核历史记录</div>
        <div class="panel-body">
            <div class="form-horizontal">
                <?php
                foreach ($authRecordItems as $authRecordItem) {
                    ?>
                    <div class="form-group">
                        <label class="col-lg-2 col-sm-2 control-label">审核状态：</label>
                        <div class="col-lg-1 control-label">
                            <?php
                            switch ($authRecordItem['status']) {
                                case 0:
                                    echo '<label class="form-control label label-default">待审核</label>';
                                    break;
                                case 1:
                                    echo '<label class="form-control label label-success">成功</label>';
                                    break;
                                case 2:
                                    echo '<label class="form-control label label-danger">失败</label>';
                                    break;
                            }
                            ?>
                        </div>
                        <label class="col-lg-2 col-sm-2 control-label">审核意见：</label>
                        <div class="col-lg-4">
                            <label class="form-control"><?= $authRecordItem['remark'] ?></label>
                        </div>
                        <label class="col-lg-2 col-sm-2 control-label">审核时间：</label>
                        <div class="col-lg-3">
                            <label class="form-control"><?= $authRecordItem['modify_datetime'] ?></label>
                        </div>
                    </div>
                    <?php
                }
                ?>
            </div>
        </div>
    </div>
</div>
<div class="modal-footer">
    <?php
    if ($currentAuthRecord != null) {
        ?>
        <input type="hidden" id="hiddenAuthId" value="<?= $currentAuthRecord['id'] ?>">
        <button class="btn btn-success" id="btnAuthOk">认证通过</button>
        <button class="btn btn-danger" id="btnAuthFailed">认证失败</button>
        <?php
    }
    ?>
    <button class="btn btn-default" data-dismiss="modal">关闭</button>
</div>


<script type="application/javascript">
    (function () {

        $('#btnAuthOk').click(function () {
            var authId = $('#hiddenAuthId').val();
            var authRemark = $('#authRemark').val().trim();
            requestJson('merchant-auth-success-handler', {auth_id: authId, auth_remark: authRemark}, true, function (responseData) {
                if (responseData.status == 0) {
                    window.location.reload();
                }
            })
        });

        $('#btnAuthFailed').click(function () {
            var authId = $('#hiddenAuthId').val();
            var authRemark = $('#authRemark').val().trim();
            requestJson('merchant-auth-failed-handler', {auth_id: authId, auth_remark: authRemark}, true, function (responseData) {
                if (responseData.status == 0) {
                    window.location.reload();
                }
            })
        });

    })(jQuery);
</script>
